// import Layout from "../pages/Layout/index";
import Layout from "../pages/Layout/index";
import Login from "../pages/Login/index";
// 配置react路由
import { createBrowserRouter } from "react-router-dom";
import { AuthPoute, AdminPoute } from "../components/AuthRoter";
// import Home from '../pages/Home/index'
// import Article from "../pages/Article";
// import Publish from "../pages/Publish";
// 配置路由懒加载
import { lazy } from "react";
import { Suspense } from "react";
const Home = lazy(() => import("../pages/Home/index"));
const Article = lazy(() => import("../pages/Article"));
const Publish = lazy(() => import("../pages/Publish"));
// 配置路由实例
const router = createBrowserRouter([
  {
    path: "/",
    element: (
      <AuthPoute>
        <Layout />
      </AuthPoute>
    ),
    // element: <Layout />,

    children: [
      {
        path: "/",
        element: (
          <AdminPoute>
            <Suspense fallback={"加载中"}>
              <Home />
            </Suspense>
          </AdminPoute>
        ),
      },
      {
        path: "article",
        element: (
          <Suspense fallback={"加载中"}>
            <Article />
          </Suspense>
        ),
      },
      {
        path: "detail",
        element: (
          <Suspense fallback={"加载中"}>
                        <Publish />         {" "}
          </Suspense>
        ),
      },
    ],
  },
  {
    path: "/login",
    element: <Login />,
  },
]);
export default router;
